package net.brucecooper.mindmap.client;

import java.util.ArrayList;

public class Node {
    public int id;
    public String name;
    public ArrayList<Integer> children;
    public ArrayList<String> votesUp;
    public ArrayList<String> votesDown;
	public String icon;
    public boolean collapsedInitially;
    public String background = "ffffff";
    public String foreground = "000000";
    public NodeOutlineStyle outline = NodeOutlineStyle.UNDERLINE;

    public Node(int id, String name, ArrayList<Integer> children) {
        this.id = id;
        this.name = name;
        this.children = children;
    }
    
    @Override
    public String toString() {
        return id + "/" + name + "/" + children;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((children == null) ? 0 : children.hashCode());
        result = prime * result + (collapsedInitially ? 1231 : 1237);
        result = prime * result + ((icon == null) ? 0 : icon.hashCode());
        result = prime * result + id;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        result = prime * result + ((votesDown == null) ? 0 : votesDown.hashCode());
        result = prime * result + ((votesUp == null) ? 0 : votesUp.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Node other = (Node) obj;
        if (children == null) {
            if (other.children != null)
                return false;
        } else if (!children.equals(other.children))
            return false;
        if (collapsedInitially != other.collapsedInitially)
            return false;
        if (icon == null) {
            if (other.icon != null)
                return false;
        } else if (!icon.equals(other.icon))
            return false;
        if (id != other.id)
            return false;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;
        if (votesDown == null) {
            if (other.votesDown != null)
                return false;
        } else if (!votesDown.equals(other.votesDown))
            return false;
        if (votesUp == null) {
            if (other.votesUp != null)
                return false;
        } else if (!votesUp.equals(other.votesUp))
            return false;
        
        if (outline == null) {
            if (other.outline != null)
                return false;
        } else if (!outline.equals(other.outline))
            return false;

        if (foreground == null) {
            if (other.foreground != null)
                return false;
        } else if (!foreground.equals(other.foreground))
            return false;
        if (background == null) {
            if (other.background != null)
                return false;
        } else if (!background.equals(other.background))
            return false;


        
        return true;
    }
    
}
